﻿using PLCS.Domain.Trays;
using PLCS.EntityFrameworkCore.EntityFrameworkCore;

namespace PLCS.EntityFrameworkCore.Trays;

public class TrayRepository : EfCoreRepository<PLCSDbContext, Tray, Guid>, ITrayRepository
{
    public TrayRepository(IDbContextProvider<PLCSDbContext> dbContextProvider) : base(dbContextProvider)
    {
    }

    public async Task<Tray?> GetTrayByNoAsync(string trayNo)
    {
        var queryable = await GetQueryableAsync();
        queryable = queryable.Where(x => x.TrayNo == trayNo).Include(x => x.Station);
        var tray = queryable.FirstOrDefault();
        return tray;
    }
}